package org.dcarew.clearcase;

import java.io.File;

/**
 * 
 * 
 * @author Devon Carew
 */
class DBFileEntry
{
    private String      name;
    
    private File        file;
    
    private int         scmLength;
    
    private boolean     checkedOut;
    
    
    public DBFileEntry(File parent, String name)
    {
        this.name = name;
        
        file = new File(parent, name);
    }
    
    public String getName()
    {
        return name;
    }

    public boolean isHijacked()
    {
        if (isCheckedOut())
            return false;
        
        if (file.isFile())
        {
            //if (parent.get)
            // TODO: check timestamp, length, ...
            
            int currentSize = (int)file.length();
            
            if (currentSize != scmLength)
                return true;
            
            if (file.canWrite())
                return true;
        }
        
        return false;
    }

    public boolean isCheckedOut()
    {
        return checkedOut;
    }
    
    public void setCheckedOut(boolean checkedOut)
    {
        this.checkedOut = checkedOut;
    }

    public void setSCMLength(int scmLength)
    {
        this.scmLength = scmLength;
    }
    
}
